package com.ruoyi.web.controller.system;

import java.util.List;

import com.ruoyi.system.domain.SysSchoolStudent;
import com.ruoyi.system.mapper.SysSchoolStudentMapper;
import com.ruoyi.system.service.ISysSchoolStudentService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysSchoolRepeater;
import com.ruoyi.system.service.ISysSchoolRepeaterService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 留级信息Controller
 * 
 * @author 杨皓焜
 * @date 2021-02-01
 */
@RestController
@RequestMapping("/system/repeater")
public class SysSchoolRepeaterController extends BaseController
{
    @Autowired
    private ISysSchoolRepeaterService sysSchoolRepeaterService;
    @Autowired
    private ISysSchoolStudentService sysSchoolStudentService;

    /**
     * 查询留级信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:repeater:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysSchoolRepeater sysSchoolRepeater)
    {
        startPage();
        List<SysSchoolRepeater> list = sysSchoolRepeaterService.selectSysSchoolRepeaterList(sysSchoolRepeater);
        return getDataTable(list);
    }

    /**
     * 查询留级信息列表
     */
    @GetMapping("/student/list")
    public TableDataInfo list(SysSchoolStudent sysSchoolStudent)
    {
        List<SysSchoolStudent> list = sysSchoolStudentService.selectSysSchoolStudentList(sysSchoolStudent);
        return getDataTable(list);
    }

    /**
     * 导出留级信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:repeater:export')")
    @Log(title = "留级信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SysSchoolRepeater sysSchoolRepeater)
    {
        List<SysSchoolRepeater> list = sysSchoolRepeaterService.selectSysSchoolRepeaterList(sysSchoolRepeater);
        ExcelUtil<SysSchoolRepeater> util = new ExcelUtil<SysSchoolRepeater>(SysSchoolRepeater.class);
        return util.exportExcel(list, "repeater");
    }

    /**
     * 获取留级信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:repeater:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(sysSchoolRepeaterService.selectSysSchoolRepeaterById(id));
    }

    /**
     * 新增留级信息
     */
    @PreAuthorize("@ss.hasPermi('system:repeater:add')")
    @Log(title = "留级信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysSchoolRepeater sysSchoolRepeater)
    {
        return toAjax(sysSchoolRepeaterService.insertSysSchoolRepeater(sysSchoolRepeater));
    }

    /**
     * 修改留级信息
     */
    @PreAuthorize("@ss.hasPermi('system:repeater:edit')")
    @Log(title = "留级信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysSchoolRepeater sysSchoolRepeater)
    {
        return toAjax(sysSchoolRepeaterService.updateSysSchoolRepeater(sysSchoolRepeater));
    }

    /**
     * 删除留级信息
     */
    @PreAuthorize("@ss.hasPermi('system:repeater:remove')")
    @Log(title = "留级信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysSchoolRepeaterService.deleteSysSchoolRepeaterByIds(ids));
    }
}
